/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Update;

import Interfaces.Loadable;
import functions.Dogy;
import functions.LogError;
import java.sql.SQLException;

/**
 *
 * @author JArik
 */
public class Updater {

        public static void update()
    {
        try
        {
            appUpdate();
            dbUpdate();
        }catch(Exception e)
        {
            LogError.reportSilentError(e);
            e.printStackTrace();
        }
    }
    public static void appUpdate()
    {
       Dogy.initLoading(1, "Проверка обновлений", new Loadable(){
            @Override
            public Object load()
            {
                Dogy.checkOnlineUpdate(Dogy.UPDATE_URL);
                return null;
            }
            public void done(Object done)
            {
            }
            @Override
            public Object cancel()
            {

                return null;
            }

            @Override
            public void progress(int p) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
    }
    public static void dbUpdate() throws SQLException
    {

        if(Dogy.DB_VERSION < DBUpdate.DB_VERSION)
            Dogy.updateVersionTo(DBUpdate.doUpdate(Dogy.DB_VERSION));

    }
}
